package com.test.java01;

import java.util.Random;

public class Game {
    /*私有化成员变量*/
    private String name;
    private int blood;

    /*空参构造*/
    public Game (){

    }
    /*带参构造*/
    public Game(String name,int blood){
        this.name=name;
        this.blood=blood;
    }
    /*Name赋值*/

    public void setName(String name) {
        this.name = name;
    }

    /*获取Name*/

    public String getName() {
        return name;
    }
    /*Blood赋值*/

    public void setBlood(int blood) {
        this.blood = blood;
    }
     /*获取Blood*/
    public int getBlood() {
        return blood;
    }
    /*攻击行为*/
    public void attack(Game people){
        String [] arr={"英俊潇洒","风流倜傥","丑陋无比","相貌平平","温柔体贴",};
        Random r=new Random();
        int lose=r.nextInt(20)+1;
        int index1=r.nextInt(5);
        int index2=r.nextInt(5);
        int remain=people.getBlood()-lose;
        remain=remain<0?0:remain;
        people.setBlood(remain);
        System.out.println(arr[index1]+'的'+this.getName()+"抡起拳头，打了"+arr[index2]+'的'+people.getName()+"一下"
                +people.getName()+"失去了了"+lose+"点血量，还剩余"+remain+"点血量。");
    }






}
